1. Technical Field
The present invention relates generally to an improved data processing system. In particular, the present invention relates to a method, apparatus, and computer instructions for atomically updating 64-bit fields in the 32-bit AIX kernel.
2. Description of Related Art
The UNIX operating system is a multi-user operating system supporting a hierarchical directory structure for the organization and maintenance of files. In contrast with a single operating system, UNIX is a class of similar operating systems. There are dozens of different implementations of UNIX, such as Advanced Interactive executive (AIX), a version of UNIX produced by International Business Machines Corporation. Each implementation is similar to use because each provides a core set of basic UNIX commands.
The UNIX operating system is organized at three levels: the kernel, shell, and utilities. The kernel is the software that manages a user program's access to the system hardware and software resources, such as scheduling tasks, managing data/file access and storage, and enforcing security mechanisms. The shell presents each user with a prompt, interprets commands typed by a user, executes user commands, and supports a custom environment for each user. The utilities provide tools and applications that offer additional functionality to the operating system.
In the AIX operating system, kernel atomic operations comprise reserve and conditional store instructions for reading and writing to a shared location. Reservation instructions and partnering conditional store instructions are often referred to as load and reserve indexed (LARX) instructions and store conditional indexed (STCX) instructions. In particular, a LARX instruction first creates a reservation for a memory location for use by a partnered STCX instruction. The STCX instruction is subsequently executed if the reservation has remained valid. In other words, if the reservation is lost, the conditional store in the STCX operation will not be performed. The reservation set by the LARX instruction may be lost if the memory location has been modified by the CPU, another CPU, or another device prior to the execution of the partnered STCX instruction. In this situation, rather than perform the conditional store instruction, the STCX will set the zero bit in the status register. A bne branch instruction, which tests this bit, will branch backwards to retry the atomic operation again. In this manner, the Atomicity code keeps refetching and conditionally writing until it determines that the memory location has not been modified between the execution of the LARX and STCX instructions.
In addition, a reservation may also be lost whenever an interrupt occurs in the AIX operating system. When an interrupt occurs, the AIX kernel always uses a LARX/STCX operation to process the interrupt. However, as a side effect of the interrupt, the interrupted program's LARX reservation will be lost. This reservation will be lost even though the LARX/STCX used while processing the interrupt is not storing into the memory location reserved by the first LARX reservation.
Kernel atomic operations allow for operating on objects that are no larger than the CPU's natural word size. A CPU's word size is the number of bits that the CPU can process at one time. For example, a CPU with a 64-bit word size can manipulate 64 bits at a time. Although atomic operations are available for maintaining 64 bit quantities under the 64-bit kernel, a problem with maintaining a 64-bit object in the 32-bit kernel when 64-bit hardware is available is that the high-order 32 bits of a 64-bit register may be lost if an interrupt occurs. The high-order bits may be lost because the 32-bit kernel does not know these high-order bits are there to preserve. Thus, since the 32-bit kernel will not know to protect the high-order bits of the 64-bit register, the 64-bit quantities in the machine registers will be silently truncated to 32-bits if an interrupt occurs.
Existing methods of maintaining a 64-bit object in the 32-bit kernel contain several disadvantages. One method utilizes locks to control access to the data object. A lock is a mechanism that controls access to a resource in an environment where there are many threads of execution. While a lock may be used to enforce concurrency control policies, this method requires that the lock must be explicitly locked and unlocked around the code which updates or accesses the object. Another method uses disablement to provide serialization. Interrupts are disabled and re-enabled around the code which updates or accesses the object. However, these approaches are problematic since they add both space and time overhead to the programs.
Given that the AIX operating system always uses a LARX instruction while processing interrupts, it would be advantageous to have a mechanism in the AIX operating system for detecting potentially damaging interruptions (which cause reservations set by the LARX instruction to be lost) without incurring any additional cost. It would further be advantageous to have a mechanism in the AIX operating system for atomically updating 64-bit fields in the 32-bit kernel by protecting the high-order 32-bits of a 64-bit register if an interrupt occurs.